﻿@model PersonalFinances.ViewModels.TransactionEditViewModel

@{
    ViewBag.Title = "Edit Transaction";
}

<h2>@ViewBag.Title</h2>

@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Transaction</legend>

        @Html.HiddenFor(model => model.Transaction.ID)
        @Html.HiddenFor(model => model.Transaction.AccountID)
        @Html.HiddenFor(model => model.Transaction.Type)
        @Html.HiddenFor(model => model.Transaction.Value)
        @Html.HiddenFor(model => model.Transaction.Date)
        @Html.HiddenFor(model => model.WasPaidTransaction)

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Transaction.Description)
            @Html.ValidationMessageFor(model => model.Transaction.Description)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Category)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Transaction.CategoryID, new SelectList(Model.Categories, "ID", "Name"))
            @Html.ValidationMessageFor(model => model.Categories)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Transaction.Paid)
        </div>
        @if (!Model.WasPaidTransaction){
            <div class="editor-field">
                @Html.EditorFor(model => model.Transaction.Paid)
                @Html.ValidationMessageFor(model => model.Transaction.Paid)
            </div>
        } else {
            <div class="display-field">
                @Html.DisplayFor(model => model.Transaction.Paid)
                @Html.HiddenFor(model => model.Transaction.Paid)
            </div>
        }

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
